package com.springboot.test.web.inter;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
@Configuration
public class BaseInterceptor implements WebMvcConfigurer {
    @Resource
    private UserInterceptor interceptor;

    /**
     * 配置拦截器,使用请求路径拦截,任何方法调用前都要经过拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(interceptor)
//                拦截app目录下的所有接口
                .addPathPatterns("/app/**")
                .addPathPatterns("/manage/**")
//                去除登录接口校验
                .excludePathPatterns("/app/user/login")
                .excludePathPatterns("/app/register/*")
                .excludePathPatterns("/app/upload/oss")
                .excludePathPatterns("/manage/user/login")
        ;
    }
}
